package com.microstation.service.impl.view;

import java.util.List;

import com.microstation.enums.ResultEnum;
import com.microstation.exception.ElementEmptyException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.microstation.service.view.UserInfoSigninViewService;
import com.microstation.dao.view.UserInfoSigninViewDao;
import com.microstation.common.Assist;
import com.microstation.common.Result;
import com.microstation.entity.po.view.UserInfoSigninView;

/**
 * UserInfoSigninView的服务接口的实现类
 *
 * @author
 */
@Service
public class UserInfoSigninViewServiceImpl implements UserInfoSigninViewService {
    private final Logger LOG = LoggerFactory.getLogger(this.getClass());

    @Autowired
    private UserInfoSigninViewDao userInfoSigninViewDao;

    @Override
    public Result find(UserInfoSigninView userInfoSigninView, Assist assist) {
        //TODO这里可以做通过Assist做添加查询
        long results = userInfoSigninViewDao.getUserInfoSigninViewRowCount(userInfoSigninView);
        List<UserInfoSigninView> result = userInfoSigninViewDao.selectUserInfoSigninView(userInfoSigninView, assist);
        return new Result(results, result);
    }

    @Override
    public Integer saveNotNull(UserInfoSigninView value) {
        if (value == null) {
            return null;
        }
        if (value.getRegNumber() == null || value.getMobile() == null) {
            throw new ElementEmptyException(ResultEnum.EMPTY.getInfo());
        }
        int result = userInfoSigninViewDao.insertNotNullUserInfoSigninView(value);
        return result;
    }

    @Override
    public UserInfoSigninView getByExample(UserInfoSigninView userInfoSigninView) {
        return userInfoSigninViewDao.selectUserInfoSigninViewObjSingle(userInfoSigninView);
    }

    @Override
    public List<UserInfoSigninView> findListByExample(UserInfoSigninView userInfoSigninView) {
        return userInfoSigninViewDao.selectUserInfoSigninViewByObj(userInfoSigninView);
    }
}